const pages = require('./build/page')
const autoprefixer = require('autoprefixer')
const pxtoviewport = require('postcss-px-to-viewport')

module.exports = {
    publicPath: './',
    lintOnSave: false,
    pages: pages,
    // 是否生成sourceMap文件
    // 开发环境配置true，方便快速定位错误（APICloud控制台输出真的很难受）
    // 生产环境配置false，构建速度更快，打包之后体积更小
    productionSourceMap: false,
    // webpack-dev-server 相关配置
    devServer: {
        open: true,
        host: '0.0.0.0',
        port: 8003,
        https: false,
        hot: true,
        hotOnly: true
    },
    // css相关配置
    css: {
        // 是否使用css分离插件 ExtractTextPlugin
        extract: true,
        // 开启 CSS source maps?
        sourceMap: false,
        // 启用 CSS requireModuleExtension for all css / pre-processor files.
        requireModuleExtension: true,
        loaderOptions: {
            postcss: {
                plugins: [
                    autoprefixer(),
                    pxtoviewport({
                        viewportWidth: 1366,
                        viewportHeight: 768,
                        unitPrecision: 3,
                        viewportUnit: 'vw',
                        selectorBlackList: ['.ignore', '.hairlines', 'van-circle__layer'],
                        minPixelValue: 1,
                        mediaQuery: false
                    })
                ]
            },
            sass: {
                prependData: `$base_color: ${
                    process.env.VUE_APP_BASE_COLOR
                    };@import "@/assets/styles/variables.scss";@import "@/assets/styles/mixin.scss";@import "@/assets/styles/schemes.scss";`
            }
        }
    }
}